package com.jx.mst.third.controller;

import com.jx.mst.third.common.dtos.ResponseResult;
import com.jx.mst.third.service.FileLogService;
import com.jx.mst.third.service.ImgService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/img")
public class ImgController {

    @Autowired
    private ImgService imgService;
    @Resource
    private FileLogService fileLogService;
    @PostMapping("/UploadImg")
    public ResponseResult UploadImg(HttpServletRequest request, MultipartFile file) throws IOException {
        String path = imgService.UploadImg(file);
        fileLogService.saveLogByFileLogDes(request,"用戶端保存面试题类型图片",path);
        return ResponseResult.okResult(path);
//        return imgService.UploadImg(file);
    }

}
